﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;

namespace shop.Model
{
    /// <summary> 在静态类中存储单据类型, 都是只读的 </summary>
    public static class DocFlagEnum
    {

        #region 静态构造函数

        /// <summary> 静态构造函数, 检查重复 </summary>
        static DocFlagEnum()
        {
            var list = typeof(DocFlagEnum).GetProperties(BindingFlags.Static | BindingFlags.Public);

            Dictionary< PropertyInfo,string> dict = new Dictionary<PropertyInfo, string>();
            foreach (PropertyInfo info in list)
            {
                dict.Add(info, info.GetValue(null,null)?.ToString());
            }

            //检查重复
            var rr= dict.Select(a=> new {a.Key.Name, a.Value})
                .GroupBy(a => a.Value)
                .Select(a => new {a.Key, repeat = a.Count()})
                .Where(x=>x.repeat>1).ToList();

            if (rr != null && rr.Count>0 )
            {
                throw  new Exception($"系统错误, 单据类型不能重复, DocFlagEnum中的属性包含重复值{rr[0].Key}");
            }

        }

        #endregion

        [Description("科目期初数据")]
        public static string JAccountBalance => nameof(JAccountBalance);
        

        [Description("期初数据")]
        public static string BeginData => nameof(BeginData);

        [Description("其他")]
        public static string Other => nameof(Other);

        [Description("配件出库单")]
        public static string OutStock => nameof(OutStock);

        [Description("配件出库单")]
        public static string BuyOrder => nameof(BuyOrder);

        [Description("生产领料单")]
        public static string ProductionConsume => nameof(ProductionConsume); 

        [Description("外购入库单")]
        public static string PurchaseInStock => nameof(PurchaseInStock);

        [Description("原料外购")]
        public static string ProductMaterial => nameof(ProductMaterial);

        [Description("销售合同")]
        public static string SalesOrder => nameof(SalesOrder);
        [Description("销售发货单")]
        public static string SalesDeliver => nameof(SalesDeliver);
        //[Description("销售发货单2")]
        //public static string SalesDeliver2 => nameof(SalesDeliver2);


        [Description("加工合同对账单")]
        public static string ProcessComplete => nameof(ProcessComplete);

        [Description("原料外购审核")]
        public static string ProductMaterialReview => nameof(ProductMaterialReview);

        [Description("标记生产外购的合同号")]
        public static string ProductMaterialMarkOrder => nameof(ProductMaterialMarkOrder);

        [Description("冷轧耗用单")]
        public static string LengzhaProdcut => nameof(LengzhaProdcut);


        [Description("银行流水")]
        public static string Bank => nameof(Bank);

        [Description("销售结算单")]
        public static string SalesBill => nameof(SalesBill);


        [Description("银行付款单")]
        public static string BankPay => nameof(BankPay);

        [Description("采购订单")]
        public static string PurchaseOrder => nameof(PurchaseOrder);

        [Description("采购申请单")]
        public static string DeviceRequest => nameof(DeviceRequest);

        [Description("采购计划")]
        public static string PurchaseTask => nameof(PurchaseTask);

        [Description("采购合同结算单")]
        public static string PurchaseOrderBill => nameof(PurchaseOrderBill);

        [Description("配件入库单")]
        public static string SupplyInStock => nameof(SupplyInStock);

        [Description("配件出库单")]
        public static string SupplyOutStock => nameof(SupplyOutStock);

        [Description("采购配件费用单")]
        public static string PurchaseFee => nameof(PurchaseFee);

        [Description("其他入库单")]
        public static string OtherStockInForm => nameof(OtherStockInForm);

        [Description("其他出库单")]
        public static string OtherStockOutForm => nameof(OtherStockOutForm);

        [Description("委外加工出库单")]
        public static string SubcontractOut => nameof(SubcontractOut);

        [Description("委外加工入库单")]
        public static string SubcontractBack => nameof(SubcontractBack);



        [Description("内部调拨")]
        public static string StockAllocationForm => nameof(StockAllocationForm);

        [Description("库存盘点")]
        public static string StockInventoryForm => nameof(StockInventoryForm);

        [Description("库存盘点")]
        public static string SInvoices => nameof(SInvoices);

        [Description("配件结算单")]
        public static string SDeviceInvoice => nameof(SDeviceInvoice);

        [Description("税票导入")]
        public static string SInvoicesImport => nameof(SInvoicesImport);

        [Description("现金收据")]
        public static string CaReceipt => nameof(CaReceipt);


        [Description("银行收款单")]
        public static string BankReceipt => nameof(BankReceipt);

        [Description("银行倒账单")]
        public static string BankTransfer => nameof(BankTransfer);

        [Description("银行付款单")]
        public static string BankPayment => nameof(BankPayment);

        [Description("承兑日记账")]
        public static string AcceptanceBill => nameof(AcceptanceBill);
        
        [Description("银行融资贷款管理")]
        public static string CaBankFinancingLoan => nameof(CaBankFinancingLoan);

        [Description("现金盘点单")]
        public static string CaCashInventory => nameof(CaCashInventory);

        [Description("等价物盘点单")]
        public static string CaEquivalentInventory => nameof(CaEquivalentInventory);

        [Description("等价物入库单")]
        public static string CaEquivalentIn => nameof(CaEquivalentIn);

        [Description("等价物出库单")]
        public static string CaEquivalentOut => nameof(CaEquivalentOut);
        
        [Description("银行对账单")]
        public static string CaBankInventory=> nameof(CaBankInventory);

        [Description("支票购置登记单")]
        public static string CaChequeBuy => nameof(CaChequeBuy);

        [Description("支票领用登记单")]
        public static string CaChequeUse => nameof(CaChequeUse);

        [Description("报销单")]
        public static string FDExpense => nameof(FDExpense);

        [Description("现金出纳")]
        public static string CaCashier => nameof(CaCashier);

        [Description("资金登记")]
        public static string Cash => nameof(Cash);


        [Description("现金出纳付款单")]
        public static string CaCashierPayment => nameof(CaCashierPayment);

        [Description("付质保金")]
        public static string SRecognizance => nameof(SRecognizance);

        [Description("设备登记")]
        public static string DeviceRegister => nameof(DeviceRegister);

        [Description("借款登记")]
        public static string CaIous => nameof(CaIous);

        [Description("外单位借款登记")]
        public static string CaExternalIous => nameof(CaExternalIous);

        [Description("外购合同订单")]
        public static string PrdtBuyOrder => nameof(PrdtBuyOrder);

        [Description("原料付款单")]
        public static string PrdtPayRecord => nameof(PrdtPayRecord);

        [Description("外购退货")]
        public static string ProductPurchaseReturn => nameof(ProductPurchaseReturn);

        [Description("带钢入库单")]
        public static string ProductPurchase => nameof(ProductPurchase);


        [Description("外购钢管")]
        public static string ProdPurchasePipe => nameof(ProdPurchasePipe);


        [Description("委外加工出库")]
        public static string PrdtSubcontractOut => nameof(PrdtSubcontractOut);

        [Description("委外加工入库")]
        public static string PrdtSubcontractBack => nameof(PrdtSubcontractBack);

        [Description("产品入库单")]
        public static string PrdtProductConsume => nameof(PrdtProductConsume);

        [Description("盘点单")]
        public static string ProductAmendment => nameof(ProductAmendment);
        
        [Description("调拨单")]
        public static string ProductAllocation => nameof(ProductAllocation);

        [Description("库存调整")]
        public static string StockAdjust => nameof(StockAdjust);

        [Description("排产")]
        public static string PrdtScheduling => nameof(PrdtScheduling);


        [Description("凭证录入")]
        public static string Voucher => nameof(Voucher);

        [Description("固定资产卡片维护")]
        public static string FixedAssetCard => nameof(FixedAssetCard);

        [Description("模式凭证")]
        public static string VrTemplate => nameof(VrTemplate);

        [Description("销售结算单")]
        public static string SalesInvoice => nameof(SalesInvoice);

        [Description("销售收款")]
        public static string SalesAmount => nameof(SalesAmount);

        [Description("出门证")]
        public static string SalesExitPermit => nameof(SalesExitPermit);

        [Description("加工出库")]
        public static string ProcessOut => nameof(ProcessOut);
        
        [Description("加工入库")]
        public static string ProcessIn => nameof(ProcessIn);

        [Description("销售发票")]
        public static string TaxInvoiceDoc => nameof(TaxInvoiceDoc);


        [Description("原料发票")]
        public static string PurchaseTax => nameof(PurchaseTax);


        [Description("开票登记")]
        public static string InvoiceTrade => nameof(InvoiceTrade);

        [Description("开票申请")]
        public static string TaxRequest => nameof(TaxRequest);


        [Description("快递核算配置")]
        public static string LogisticsFeeConfig => nameof(LogisticsFeeConfig);


        [Description("退换货登记")]
        public static string RefundRegist => nameof(RefundRegist);


        [Description("店铺登录信息")]
        public static string ShopLogin => nameof(ShopLogin);


    }


}
